package com.xthink.web.controller;

import com.xthink.common.result.AjaxResult;
import com.xthink.common.vo.pool.*;
import com.xthink.web.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/pool")
public class PoolController {
    @Autowired
    private PoolService poolService;

    @Autowired
    private GroupTotalService groupTotalService;

    @Autowired
    private PoolGroupService poolGroupService;

    @Autowired
    private CardsService cardsService;

    @Autowired
    private PoolAndPackageService poolAndPackageService;

    @Autowired
    private WarningRecordService warningRecordService;

    @Autowired
    private PoolOrderService poolOrderService;

    //新建流量池
    @PostMapping("/insertPool")
    public AjaxResult insertPool(@RequestBody InsertPoolVo insertPoolVo){
        return poolService.insertPool(insertPoolVo);
    }

    //分页查询及模糊搜索
    @PostMapping("/list")
    public AjaxResult poolList(@RequestBody PoolListVo poolListVo){
        return poolService.poolList(poolListVo);
    }

    //上架
    @GetMapping("/putOn/{ids}")
    public AjaxResult putOnPool(@PathVariable("ids")Integer[] ids){
        return poolService.putOnPool(ids);
    }

    //下架
    @GetMapping("/putOff/{ids}")
    public AjaxResult putOffPool(@PathVariable("ids")Integer[] ids){
        return poolService.putOffPool(ids);
    }

    //删除
    @GetMapping("/deletePool/{ids}")
    public AjaxResult deletePool(@PathVariable("ids")Integer[] ids){
        return poolService.deletePool(ids);
    }

    //绑定池套餐
    @GetMapping("/binDingPoolPackage/{poolIds}/{poolPackageId}")
    public AjaxResult binDingPoolPackage(@PathVariable("poolIds")Integer[] poolIds,@PathVariable("poolPackageId")Integer poolPackageId){
        return poolService.binDingPoolPackage(poolIds,poolPackageId);
    }

    //解绑池套餐 套餐数据回显
    @GetMapping("/unBinDingPoolPackage/{poolId}")
    public AjaxResult unBinDingPoolPackage(@PathVariable("poolId") Integer poolId){
        return poolAndPackageService.unBinDingPoolPackage(poolId);
    }

    //解绑池套餐
    @GetMapping("/unBinDingPoolPackage/{poolIds}/{poolPackageId}")
    public AjaxResult unBinDingPoolPackage(@PathVariable("poolIds")Integer[] poolIds,@PathVariable("poolPackageId")Integer poolPackageId){
        return poolService.unBinDingPoolPackage(poolIds,poolPackageId);
    }

    //流量池编辑数据回显
    @GetMapping("/updatePool/{id}")
    public AjaxResult updatePoolId(@PathVariable("id") Integer id){
        return poolService.updatePoolId(id);
    }

    //流量池编辑
    @PostMapping("/updatePool")
    private AjaxResult updatePool (@RequestBody UpdatePoolVo updatePoolVo){
        return poolService.updatePool(updatePoolVo);
    }

    //池详情
    @GetMapping("/details/{id}")
    public AjaxResult detailsPool(@PathVariable("id")Integer id){
        return poolService.detailsPool(id);
    }

    //小组下拉框
    @GetMapping("/selectGroup/{id}")
    public AjaxResult selectGroup(@PathVariable("id")Integer id){
        return poolGroupService.selectGroup(id);
    }

    //池成员分页查询及搜索
    @PostMapping("/groupTotalList")
    public AjaxResult groupTotalList(@RequestBody GroupTotalListVo groupTotalListVo){
        return groupTotalService.groupTotalList(groupTotalListVo);
    }

    //绑定池卡片回显
    @PostMapping("/poolCardList")
    public AjaxResult poolCardList(@RequestBody PoolCardListVo poolCardListVo){
        return cardsService.poolCardList(poolCardListVo);
    }

    //绑定池卡片
    @PostMapping("/insertGroupTotal")
    public AjaxResult insertGroupTotal(@RequestBody InsertGroupTotalVo insertGroupTotalVo){
        return groupTotalService.insertGroupTotal(insertGroupTotalVo);
    }

    //解绑池卡片回显
    @PostMapping("/deleteGroupTotal")
    public AjaxResult deletePoolGroupTotal(@RequestBody PoolCardListVo poolCardListVo){
        return cardsService.deletePoolGroupTotal(poolCardListVo);
    }

    //解绑池卡片
    @GetMapping("/deleteGroupTotal/{ids}")
    public AjaxResult deleteGroupTotal(@PathVariable("ids") Integer[] ids){
        return groupTotalService.deleteGroupTotal(ids);
    }

    //调拨小组卡片回显
    @GetMapping("/listCards/{ids}")
    public AjaxResult listCards(@PathVariable("ids") Integer[] ids){
        return groupTotalService.listCards(ids);
    }

    //调拨小组卡片
    @GetMapping("/updateGroupTotal/{ids}/{id}")
    public AjaxResult updateGroupTotal(@PathVariable("ids") Integer[] ids,@PathVariable("id") Integer id){
        return groupTotalService.updateGroupTotal(ids,id);
    }

    //流量池内部池套餐详情
    @PostMapping ("/listPoolPackage")
    public AjaxResult listPoolPackage(@RequestBody PoolAndPackageLikeListVo poolAndPackageLikeListVo){
        return poolAndPackageService.listPoolPackage(poolAndPackageLikeListVo);
    }

    //流量池内部添加小组
    @PostMapping("/insertGroup")
    public AjaxResult insertGroup(@RequestBody InsertGroupVo insertGroupVo){
        return poolGroupService.insertGroup(insertGroupVo);
    }

    //流量池内部查询小组
    @PostMapping("/listGroup")
    public AjaxResult listGroup(@RequestBody ListGroupVo listGroupVo){
        return poolGroupService.listGroup(listGroupVo);
    }

    //流量池内部删除小组
    @GetMapping("/deleteGroup/{id}")
    public AjaxResult deleteGroup(@PathVariable("id") Integer id){
        return poolGroupService.deleteGroup(id);
    }

    //流量池警告记录查询
    @PostMapping("/listRecord")
    public AjaxResult listRecord(@RequestBody ListWarningRecordVo listWarningRecordVo){
        return warningRecordService.listRecord(listWarningRecordVo);
    }

    //流量池详情池订单查询
    @PostMapping("/listPoolIdOrder")
    public AjaxResult listPoolIdOrder(@RequestBody ListPoolOrderVo listPoolOrderVo){
        return poolOrderService.listPoolIdOrder(listPoolOrderVo);
    }

    //订单池查询
    @PostMapping("/listPoolOrder")
    public AjaxResult listPoolOrder(@RequestBody ListPoolOrderVo listPoolOrderVo){
        return poolOrderService.listPoolOrder(listPoolOrderVo);
    }
}
